﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class wallUD : MonoBehaviour
{
    public AudioSource m_Ding;
    public Platform m_PlatformUp;
    public Platform m_PlatformDown;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnTriggerEnter2D(Collider2D collder)
    {
        if (collder == null)
            return;
        Ball ball = collder.GetComponent<Ball>();
        if (ball == null)
            return;
        Player playerDown = m_PlatformDown.m_Player;
        Player playerUp = m_PlatformUp.m_Player;
        if (ball.transform.position.y > 0)
        {
            playerDown.addPoint();
            Debug.Log("down win");
        }
        else
        {
            playerUp.addPoint();
        }
        Destroy(collder.gameObject);

        if (m_Ding)
            m_Ding.Play();
    }
}
